<html>
<head>
    <script>
    function test() {
        if (window.testRunner) {
            testRunner.setPopupBlockingEnabled(false);
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
        }

        newWindow = window.open('resources/early-document-access-popup.html');
        if (newWindow) {
            newWindow.document; // access the document
        } else {
            document.body.innerText = 'FAIL: window.open failed to make a window.';
            if (window.testRunner)
                testRunner.notifyDone();
        }
    }

    function done() {
        if (window.testRunner)
            if (testRunner.windowCount() == 1)
                testRunner.notifyDone();
            else
                setTimeout("done()", 100);
    }

    function pass() {
        document.body.innerText = 'PASS';
        newWindow.close();
        done();
    }

    function fail() {
        document.body.innerText = 'FAIL';
        newWindow.close();
        done();
    }
    </script>
</head>
<body onload="test()">
FAIL: TEST DID NOT RUN!
</body>
</html>
